package com.beta.em.product;

import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * Created by vector on 2017/2/16.
 */
public enum SaleStatus {

    ON("on", "上架"),
    OFF("off", "下架");

    public final String value;
    public final String cnValue;

    SaleStatus(String value, String cnValue) {
        this.value = value;
        this.cnValue = cnValue;
    }

    public static boolean isCourierType(String username) {
        return StringUtils.startsWithIgnoreCase(username, "w");
    }

    public static SaleStatus getStatus(String value) {
        for (SaleStatus saleStatus: values()) {
            if (saleStatus.value.equals(value)) {
                return saleStatus;
            }
        }
        return null;
    }

    public static String getCnValue(String value) {
        SaleStatus saleStatus = getStatus(value);
        if (Objects.nonNull(saleStatus)) {
            return saleStatus.cnValue;
        } else {
            return "";
        }
    }
}
